package org.javacore.collection.list;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by Administrator on 2017/2/15.
 * List的contains方法。
 */
public class ListContain {
    public static void main(String[] args) {
        List<Integer> s1 = new ArrayList<>(Arrays.asList(1,2,3));
        List<Integer> s2 = new ArrayList<>(Arrays.asList(4,2,5));
        System.out.println(getUnion(s1,s2));
    }

    /**
     * 获取list中不同对象的个数
     * @param s1
     * @param s2
     * @return
     */
    public static int getUnion(List s1,List s2){
        int count = s1.size();
        for (Object o : s2){
            if (!s1.contains(o)){
                count++;
            }
        }
        return count;
    }
}
